﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Doo_JetDAL;
using DoodJetView.Core;

namespace DoodJetView.VuesPartielles
{
    /// <summary>
    /// Logique d'interaction pour EmployerForm.xaml
    /// </summary>
    public partial class EmployerForm : UserControl
    {
        public EmployerForm()
        {
            InitializeComponent();
        }
        public EmployerForm(string nom, string prenom, string VisiteMed, string NumSecu)
        {
            InitializeComponent();
            txtb_nom.Text = nom;
            txtb_prenom.Text = prenom;
            //txtb_datevisi.Text = VisiteMed;
            txtb_numSecu.Text = NumSecu;
        }
        public EmployerForm(employes emp, string titre)
        {
            InitializeComponent();
            txtb_nom.Text = emp.nomEmploye;
            txtb_prenom.Text = emp.prenomEmploye;
           // txtb_datevisi.Text = "TODO-TODO";
            txtb_numSecu.Text = emp.numSecu;
            lbl_titre.Content = titre;
        }
        public void ClearData() {
            txtb_nom.Text = String.Empty;
            txtb_prenom.Text = String.Empty;
          //  txtb_datevisi.Text = String.Empty;
            txtb_numSecu.Text = String.Empty;
        }
        public void btn_Submit_Click(object sender, RoutedEventArgs e)
        {
            
            using (DataEntities cont = new DataEntities()) {
                var emplo = new employes { nomEmploye = txtb_nom.Text, prenomEmploye = txtb_prenom.Text, DateVisiteMed = DateTimeUnixTools.ConvertToUnixTimestamp((DateTime)datePicker1.SelectedDate), numSecu = txtb_numSecu.Text };
                cont.employes.AddObject(emplo);
                cont.SaveChanges();

                cont.employes.Where(o => o.nomEmploye == "123").ToList();
            
            }
            MessageBox.Show("Enregistrement à faire :)", "ToDO", MessageBoxButton.OK);

        }
    }
}
